<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let s_age = Symbol('s_age')
    let p_s_age = Symbol('p_s_age')
    let obj = {
        age: 1,
        [s_age]: 2,
    }

    obj.__proto__.p_age = 10
    obj.__proto__[p_s_age] = 11

    console.log(obj);
    /*  结果
        age: 1
        Symbol(s_age): 2
        __proto__:
            p_age: 10
            Symbol(p_s_age): 11
     */

    /*
        开始遍历
     */

    // 1.获取自身普通属性
    console.log(Object.getOwnPropertyNames(obj)); // ['age']

    // 2.获取自身的Symbol属性
    console.log(Object.getOwnPropertySymbols(obj)) // [Symbol(s_age)]

    // 3.自身的属性, 单个,普通和symbol都可以获取
    // {value: 2, writable: true, enumerable: true, configurable: true}
    console.log(Object.getOwnPropertyDescriptor(obj, s_age))

    // 4.自身的属性,全部
    /*
        age: {value: 1, writable: true, enumerable: true, configurable: true}
        Symbol(s_age): {value: 2, writable: true, enumerable: true, configurable: true}
        __proto__: Object
     */
    console.log(Object.getOwnPropertyDescriptors(obj))

    // 5.获取原型上的属性
    /*
        p_age: 10
        Symbol(p_s_age): 11
     */
    // Object.getPrototypeOf(obj) === obj.__proto__ 返回true
    console.log(Object.getPrototypeOf(obj))

    // 6.for-in 遍历 ,遍历出所有的可以遍历的非Symbol属性 
    // age p_age
    for (let prop in obj) {
        console.log(prop)
    }

    // 7. 判断对象是否在原型上
    function hasPrototypeProperty(object, name) {
        return !object.hasOwnProperty(name) && (name in object)
    }


</script>
</body>
</html>